package org.hackystat.app.projectstatus.timer;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimerTask;

import org.hackystat.app.projectstatus.view.AlertEmailManagerUpdate;
import org.hackystat.core.kernel.user.User;
import org.hackystat.core.kernel.user.UserManager;

/**
 * Generates an HTML email if the Alert is Triggered.
 * 
 * @author Josh
 * 
 */
public class ProjectStatusTimerTask extends TimerTask {

  /** Task list. */
  private List<TimerTask> taskList;

  /** Creates a new ProjectStatusTimerTask that collects and invokes individual timer tasks. */
  public ProjectStatusTimerTask() {
    this.taskList = new ArrayList<TimerTask>();
  }

  /**
   * Must be implemented by the DailyTimer task manager once a day at 2am.
   */
  public void run() {
    ArrayList<String> emailedUsers = new ArrayList<String>();
    UserManager userManager = UserManager.getInstance();
    // When Hackystat is shut down, these timers will still run once more.
    // This prevents an NPE.
    User admin = userManager.getAdminUser();
    sendUserEmailIfTriggeredAlert(emailedUsers);
  }

  /**
   * Makes calls to the ProjectStatusHTMLMailer class to send the email depending on whether the
   * alert is enabled.
   * 
   * @param user The user.
   * @param emailedUsers A list that gets updated with if the user is sent an email.
   */
  private void sendUserEmailIfTriggeredAlert(ArrayList<String> emailedUsers) {
    System.out.println("Timer Task Invoked at " + new Date());
    
  }

}
